using System;
using System.IO;

namespace RazorGenerator
{
	/// <summary>
	/// @helper使用的类型
	/// </summary>
	public class HelperTemplate
	{
		private readonly TextWriter textWriter = new StringWriter();

		/// <summary>
		/// 构造方法
		/// </summary>
		/// <param name="action"></param>
		public HelperTemplate(Action<TextWriter> action)
		{
			action?.Invoke(textWriter);
		}

		public override string ToString()
		{
			return textWriter.ToString();
		}

		~HelperTemplate()
		{
			textWriter?.Dispose();
		}
	}
}
